home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / MISC.SWG / 0003_EJect a CD-ROM.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-02-21  |  1.7 KB  |  45 lines

  1.  
  2. function MSCDEXFN : string;
  3. var s : string;
  4.     f : text;
  5.     i : byte;
  6.     fmSave : byte;
  7. begin
  8.   mscdexfn := '';                  { To indicate not found }
  9.   fmSave := FileMode;              { Store the original file mode }
  10.   FileMode := 0;                   { Also if read-only }
  11.   Assign (f, 'r:\autoexec.bat');   { Browse the AUTOEXEC.BAT }
  12.   {$I-} Reset (f); {$I+}
  13.   if IOResult <> 0 then exit;      { AUTOEXEC.BAT not found }
  14.   while not eof(f) do begin        { Line by line }
  15.     readln (f, s);
  16.     for i := 1 to Length(s) do s[i] := Upcase(s[i]);
  17.     if Pos('MSCDEX', s) > 0 then begin      { Is this the line }
  18.       if Pos ('REM', s) = 1 then continue;  { Skip rem lines }
  19.       Close (f);
  20.       FileMode := fmSave;          { Restore the original mode }
  21.       i := Pos('/D:', s);          { Look for the switch }
  22.       if i = 0 then exit;          { Nah! }
  23.       i := i + 3;                  { Where the name should start }
  24.       if i > Length(s) then exit;  { Nothing there! }
  25.       s := Copy (s, i, 255);       { Rest of the line after /D: }
  26.       mscdexfn := s;
  27.       i := Pos (' ', s);
  28.       if i = 0 then exit;
  29.       mscdexfn := Copy (s, 1, i-1);
  30.       exit;                        { Don't close twice }
  31.     end; {if}
  32.   end; {while}
  33.   Close (f);
  34.   FileMode := fmSave;              { Restore the original mode }
  35. end; (* mscdexfn *)
  36.  
  37.    All the best, Timo
  38.  
  39. ....................................................................
  40. Prof. Timo Salmi   Co-moderator of news:comp.archives.msdos.announce
  41. Moderating at ftp:// & http://garbo.uwasa.fi archives  193.166.120.5
  42. Department of Accounting and Business Finance  ; University of Vaasa
  43. ts@uwasa.fi http://uwasa.fi/~ts BBS 961-3170972; FIN-65101,  Finland
  44.  
  45.